<?php


class TbfI8nTest extends TbfTestCase{
    protected $oldConfigPath;
    function setUp(){
        $this->oldConfigPath = TbfConfig::$ConfigPath;
        TbfConfig::$ConfigPath = __DIR__.'/Resources/config';
        TbfI18n::clearCache();
    }
    function tearDown(){
        TbfConfig::$ConfigPath = $this->oldConfigPath;
    }
    function testTran(){
        TbfI18n::setLanguageCode('en');
        $this->assertSame('China',TbfI18n::tran('CN'));

        TbfI18n::setLanguageCode('zh');
        $this->assertSame('中国',TbfI18n::tran('CN'));
    }

    function testGetLanguageCode(){
        TbfI18n::setLanguageCode('en');
        $code = TbfI18n::getLanguageCode();
        $this->assertSame('en',$code);

        TbfI18n::clearCache();
        $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW,zh;q=0.8,zh-CN;q=0.6,en;q=0.4';
        $code = TbfI18n::getLanguageCode();
        $this->assertSame('zh',$code);
    }

    function testGetCurrencyList(){
        $data = TbfI18n::getCurrencyCodeList();
        $this->assertSame(count($data),count(array_unique($data)));
    }
} 